<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #box {
        height: 500px;
        width: 300px;
        overflow: auto;
      }
      .list-item {
        height: 40px;
        width: 100%;
      }
    </style>
  </head>
  <body>
    <div id="box"></div>
    <script>
      var oFragmeng = document.createDocumentFragment();
      let box = document.getElementById("box");
      function addList() {
        for (let i = 0; i < 100; i++) {
          let list = document.createElement("li");
          list.innerHTML = "dasjdiiioh";
          list.className = "list-item";
          oFragmeng.appendChild(list);
        }
        box.appendChild(oFragmeng);
      }
      addList();
      console.log(box.scrollHeight);
      box.onscroll = function (e) {
        let top = box.scrollTop;
        let height = box.clientHeight;
        let Top = top + height;
        if (Top >= box.scrollHeight) {
          console.log("触底了");
          addList();
        }
      };
    </script>
  </body>
</html>
